const mongoose = require('mongoose');
// mongoose.connect('mongodb://localhost/todo', { useNewUrlParser: true, useUnifiedTopology: true });
mongoose.set('useNewUrlParser', true)
mongoose.set('useFindAndModify', false)
mongoose.set('useCreateIndex', true)
mongoose.set('useUnifiedTopology',true)
const db = mongoose.createConnection('mongodb://localhost/todo');
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function () {
  // we're connected!
  console.log("connected!");

});
module.exports = {
  mongoose: mongoose,
  db: db
}